package lib::TextInput;

# This file is part of noplagia.
#
# noplagia is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# noplagia is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# noplagia; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA  02111-1307 USA

use strict;
use Lingua::StopWords qw( getStopWords );

require Exporter;
our ($VERSION,@ISA,@EXPORT,$context);

$VERSION = 0.01;

=head1 NAME

lib::Textinput - analyse un fichier texte brute et le retourne decoupe

=head1 SYNOPSIS

  use CGI;
  use lib::Textinput
      
  my $text = qq/
    le partiel de cobol etait long difficile et il n'y avait pas de neige.
  /;
  
  my $text_decoupe = format_text($text);

=head1 DESCRIPTION

    Ce module permet de charger un template en verifiant les droits dessus.
    Il permet aussi d'ecrire un template avec ces entetes et cookie

=head1 FUNCTIONS

=over 2

=cut

@ISA    = qw(Exporter);
@EXPORT = qw(
  &format_text
);

=item format_text

 TODO description de la fonction format_text

=cut

sub format_text {
    my $text = shift;
    
    my @return; # ne pas prendre un tableau mais un hash qui contiendrait (full => $text, stopwords => $text_sans_les_stops_words ...)
    # on met d'abord le texte en entier.
    push @return, $text;
    
    # on met d'abord le texte en entier sans les stopwords
    my $stopwords = getStopWords('fr'); # FIXME :: hardcoded !
    push @return , join ' ', grep { !$stopwords->{$_} } split /\s/, $text;
    
    return \@return;
}

END { }
1;
__END__

=back

=head1 AUTEUR

    noplagia dev team

    http://noplagia.org

=cut
